#ifndef HTTPUTIL_H
#define HTTPUTIL_H

#include <string>
using std::string;

namespace HTTPUtil {

    enum HTTPMethod {
        MethodGET,
        MethodPOST,
        MethodHEAD,
        nMethod
    };

    const string methodString(HTTPMethod method);
    // read a line from fd to `str', always block until really
    // read a whole line (match a \n or EOF), or any error
    // occured (return false)
    bool readline(string& str, bool *eof, int fd);

    bool parseRequestLine(HTTPMethod& method, string& path, string& version, const string& str);
    bool readBytes(string& buffer, int fd, int length);
    bool writeBytes(const char* buffer, int fd, int length);
    bool copy(int infd, int outfd, int length);
};
#endif
